package com.example.toutiao.http

import com.example.toutiao.mvp.model.BaseModel
import com.example.toutiao.ui.main.model.*
import io.reactivex.Observable
import okhttp3.MultipartBody
import retrofit2.http.*

interface UserApi {
    @GET(value = "/user")
    fun getTest(): Observable<BaseModel<MainModel>>

    @FormUrlEncoded
    @POST("/sendCode")
    fun getCode(@Field("phoneNumber")phone:String):Observable<BaseModel<CodeModel>>

    @FormUrlEncoded
    @POST("/register")
    fun getRegister(
        @Field("phoneNumber") phone: String,
        @Field("verificationCode") code:String,
        @Field("onlyIdentifier") ider:Int,
        @Field("type") type:Int
    ):Observable<BaseModel<RegisterModel>>

    @FormUrlEncoded
    @POST("/login")
    fun login(
        @Field("phone") phone: String,
        @Field("password") password:String
    ):Observable<BaseModel<LoginModel>>

    @FormUrlEncoded
    @POST("/setPassword")
    fun setPassword(
        @Field("phone") phone: String,
        @Field("password") password:String
    ):Observable<BaseModel<RegisterModel>>

    @GET("myList")
    fun getCommList(@Query("type") type:Int):Observable<BaseModel<List<CommonModel>>>

    @GET("/userInfo")
    fun getUserInfo(@Header("token") token:String):Observable<BaseModel<UserInfoModel>>

    @GET("/province")
    fun getProvince():Observable<BaseModel<List<AddressModel>>>

    @GET("/city")
    fun getCity(@Query("code") code:Int):Observable<BaseModel<List<AddressModel>>>

    @Multipart
    @POST("/upload")
    fun uploadImage(@Part file: MultipartBody.Part,@Header("token") token:String):Observable<BaseModel<String>>

    @FormUrlEncoded
    @POST("/setPart")
    fun setPart(@Header("token") token:String,@FieldMap partMap: MutableMap<String,String>):Observable<BaseModel<String>>

    @GET("/minVideo")
    fun getMinVideo():Observable<BaseModel<List<MinVideoModel>>>

    @GET("/video")
    fun getVideo(@Query("id") id:String):Observable<BaseModel<List<VideoModel>>>

    @GET("/tabIds")
    fun getTabIds():Observable<BaseModel<List<TabIdsModel>>>

    @GET("/recommend")
    fun getRecommend():Observable<BaseModel<List<RecommenModel>>>

    @GET("/recommendList")
    fun getSearchHis():Observable<BaseModel<RecMainModel>>

    @GET("/channel")
    fun getChannel():Observable<BaseModel<TabListModel>>

}